package top.shaozuo.mybatis.spring.boot.autoconfigure;

import javax.sql.DataSource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Configuration;

import top.shaozuo.simple.mybatis.annotation.EnableMybatis;

@Configuration
@ConditionalOnClass({ SqlSessionFactory.class, SqlSessionFactoryBean.class })
@ConditionalOnSingleCandidate(DataSource.class)
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
public class MybatisAutoConfiguration {

	@Configuration
	@EnableMybatis(dataSource = "dataSource", configLocation = "",
	        basePackages = "${simple.mybatis.basePackages}",
	        typeHandlersPackage = "${simple.mybatis.typeHandlersPackage}")
	static class MybatisConfiguration {

	}

}
